#!/usr/bin/env python 
# -*- coding:utf-8 -*-

from flask import Flask, redirect, url_for
app = Flask(__name__)

@app.route('/hello')
def hello_world():
    return 'Hello World!'

@app.route('/index2')
def index():
    return 'index。'
app.add_url_rule('/','index',index)


# 默认输入为string
@app.route('/uid/<uid>')
def get_user_id(uid):
    return 'UID:{}'.format(uid)

@app.route('/ybx/<name>')
def show_name(name):
    return 'Your Name:{}'.format(name)

# 限制输入类型为float
@app.route('/post/<float:post_id>')
def show_post(post_id):
    return 'PostId:{}'.format(post_id)


@app.route('/admin/<name>')
def admin(name):
    if name == 'index':
        return redirect(url_for('index'))
    elif name == 'uid':
        return redirect(url_for('get_user_id',uid=123456))
    else:
        return redirect(url_for('show_name', name='hhhh'))

if __name__ == '__main__':
    app.debug = True
    app.run('0.0.0.0')